#include <iostream>
#include <vector>

/**
 * NowCoder KY39: Factors of Big Integers
 */

struct BigInt {
    std::vector<uint8_t> digits;

    BigInt(const std::string &str) {
        digits.reserve(str.length());
        for (int i = 0; i < str.length(); i++)
            digits.push_back(str[i] - '0');
    }

    bool hasFactor(uint8_t fac) const {
        uint8_t rem = 0;
        for (int i = 0; i < digits.size(); i++) {
            rem = rem * 10 + digits[i];
            rem %= fac;
        }
        return rem == 0;
    }
};

std::vector<std::vector<uint8_t> > factors;

int main() {
    // Precompute factors of 2-9
    factors = std::vector<std::vector<uint8_t> >(10);
    factors[4].push_back(2);
    factors[6].push_back(2);
    factors[6].push_back(3);
    factors[8].push_back(2);
    factors[8].push_back(4);
    factors[9].push_back(3);

    std::string str;
    while (std::cin >> str) {
        // Judge factors
        if (str == "-1") continue;
        BigInt value(str);
        std::vector<bool> isFactor(10, false);
        for (uint8_t fac = 9; fac >= 2; fac--) {
            if (isFactor[fac]) continue;
            if (!value.hasFactor(fac)) continue;
            isFactor[fac] = true;
            for (int i = 0; i < factors[fac].size(); i++)
                isFactor[factors[fac][i]] = true;
        }

        // Print
        bool first = true;
        for (int i = 2; i <= 9; i++) {
            if (!isFactor[i]) continue;
            if (first) 
                first = false;
            else
                printf(" ");
            printf("%d", i);
        }
        if (first) printf("none");
        printf("\n");
    }
}